package com.hziee.graduate.ticket.controller;



import com.hziee.graduate.ticket.dto.R;
import com.hziee.graduate.ticket.entity.Schedule;
import com.hziee.graduate.ticket.service.ScheduleService;
import com.hziee.graduate.ticket.vo.CascaderVO;
import com.hziee.graduate.ticket.vo.EntryVO;
import com.hziee.graduate.ticket.vo.ScheduleVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;
import java.io.Serializable;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("schedule")
public class ScheduleController {

    @Resource
    private ScheduleService scheduleService;

    @PostMapping("/getScheduleByDate")
    public R<List<ScheduleVO>> getScheduleByDate(@RequestBody Map<String,Object> map) {
        return scheduleService.getScheduleByDate(map);
    }

    @GetMapping("/delScheduleById/{scheduleId}")
    public R<Schedule> delScheduleById(@PathVariable Long scheduleId) {
        return scheduleService.delScheduleById(scheduleId);
    }

    @PostMapping("/addSchedule")
    public R<Schedule> addSchedule(@RequestBody Map<String,Object> map) {
        return scheduleService.addSchedule(map);
    }

    @GetMapping("/getCascaderOptionByMovie/{movieId}/{date}/{cityname}")
    public R<List<CascaderVO>> getCascaderOptionByMovie(@PathVariable Long movieId, @PathVariable String date, @PathVariable String cityname) {
        return scheduleService.getCascaderOptionByMovie(movieId,date,cityname);
    }

    @GetMapping("/getScheduleById/{scheduleId}")
    public R<Schedule> getScheduleById(@PathVariable("scheduleId") Long scheduleId) {
        Schedule byId = scheduleService.getById(scheduleId);
        if(byId!=null) return R.success(byId);
        else return R.error();
    }

    @GetMapping("/getEntryInfoByCinemaId/{cinemaId}")
    public R<List<EntryVO>> getEntryInfoByCinemaId(@PathVariable("cinemaId") Long cinemaId) {
        return scheduleService.getEntryInfoByCinemaId(cinemaId);
    }

}

